﻿using System;
using System.Data;
using System.Collections.Generic;
using WeiXinPF.Common;
using WeiXinPF.Model;

namespace WeiXinPF.BLL
{
    public partial class wx_shop_product_comment
    {
        private readonly WeiXinPF.DAL.wx_shop_product_comment dal = new WeiXinPF.DAL.wx_shop_product_comment();

        public int SaveComment(Model.wx_shop_product_comment model)
        {
            return dal.SaveComment(model);
        }

        public bool Exists(int orderId, int productid)
        {
            return dal.Exists(orderId,productid);
        }

        public dynamic GetAverageComment(int productid)
        {
            return dal.GetAverageComment(productid);

        }

        public List<Model.wx_shop_product_comment> GetApprovedCommentsByProductId(int pageIndex, int pageSize, int productid, AduitStatus status, out int totalcount)
        {
            return dal.GetApprovedCommentsByProductId(pageIndex,pageSize,productid,status,out totalcount);
        }


        public List<Model.wx_shop_product_comment> GetApproveCommentsByPage(int pageIndex, int pageSize,AduitStatus status, out int totalcount)
        {
            return dal.GetApproveCommentsByPage(pageIndex, pageSize, status, out totalcount);
        }

        public string getJSONbyCommentOnRankAndStatusByPage(int pageIndex, int pageSize, int ProductId, RankLevel ranklevel, AduitStatus status)
        {
            int totalCount;
            List<Model.wx_shop_product_comment> modellist = dal.GetCommentOnRankAndStatusByPage(pageIndex, pageSize, ProductId, ranklevel, status, out totalCount);
            wx_shop_product_commentjson json = new wx_shop_product_commentjson();
            json.commentlist = modellist;
            json.totalcount = totalCount;
            return JSONHelper.ObjectToJson(json);
        }

        public List<Model.wx_shop_product_comment> GetCommentOnRankAndStatusByPage(int pageIndex, int pageSize,int ProductId, RankLevel ranklevel, AduitStatus status, out int totalCount)
        {
            return dal.GetCommentOnRankAndStatusByPage(pageIndex,pageSize, ProductId, ranklevel, status,out totalCount);
        }

        public List<Model.wx_shop_product_comment> GetAllCommentsbyPage(int pageIndex, int pageSize, out int totalcount)
        {
            return dal.GetAllCommentsbyPage(pageIndex, pageSize, out totalcount);
        }

        public void ApproveComment(int commentid, AduitStatus status, int Auditor)
        {
            dal.ApproveComment(commentid, status , Auditor);
        }

        public void DeleteComment(int commentid)
        {
            dal.DeleteComment(commentid);
        }



        public void UpdateComment(Model.wx_shop_product_comment model)
        {
            dal.UpdateComment(model);
        }

        public Model.AduitStatus inttoenum(int status)
        {
            return (Model.AduitStatus)status;
        }

        public Model.AduitStatus stringtoenum(string status)
        {
           return  (Model.AduitStatus)Enum.Parse(typeof(Model.AduitStatus), "中国");
        }

        public void ApproveAllComment(int Auditor)
        {
            dal.ApproveAllComment(Auditor);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public wx_shop_product_comment_stat GetProductCommentStatistics(int productId)
        {
            return dal.GetProductCommentStatistics(productId);
        }

    }
}